package com.jx.common.util;

public class ObjUtil {


    /**
     * 转Integer
     */
    public static Integer covToInt(Object obj) {
        if (obj == null) {
            return 0;
        }
        if (obj instanceof Integer) {
            return (Integer) obj;
        } else if (obj instanceof Long) {
            return ((Long) obj).intValue();
        } else if (obj instanceof Double) {
            return ((Double) obj).intValue();
        } else if (obj instanceof String) {
            return Integer.parseInt((String) obj);
        }
        return 0;
    }

    /**
     * 转字符串
     */
    public static String covToString(Object obj) {
        if (obj == null) {
            return "";
        }
        return obj.toString();
    }


}
